package game.console;


public abstract class AbstractIteratorConsoleStream<TYPE> implements IConsoleStream
{
    private TYPE[] values;
    private int index = 0;
    
    protected abstract TYPE[] getValues();
    
    protected abstract String getMessage(TYPE current);
    
    protected int getIndex()
    {
        return index;
    }
    
    @Override
    public String readLine()
    {
        if (values == null)
        {
            values = getValues();
        }
        if (index < values.length)
        {
            return getMessage(values[index++]);
        }
        return null;
    }
}
